/**
 * <copyright>
 * </copyright>
 *

 */
package org.dslintegration.mRules.impl;

import org.dslintegration.mRules.Expression;
import org.dslintegration.mRules.MRulesPackage;
import org.dslintegration.mRules.Output;
import org.dslintegration.mRules.RuleStatement;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Rule Statement</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dslintegration.mRules.impl.RuleStatementImpl#getStatement <em>Statement</em>}</li>
 *   <li>{@link org.dslintegration.mRules.impl.RuleStatementImpl#getExpession <em>Expession</em>}</li>
 *   <li>{@link org.dslintegration.mRules.impl.RuleStatementImpl#getOutput <em>Output</em>}</li>
 *   <li>{@link org.dslintegration.mRules.impl.RuleStatementImpl#getOutputAttribute <em>Output Attribute</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RuleStatementImpl extends MinimalEObjectImpl.Container implements RuleStatement
{
  /**
   * The default value of the '{@link #getStatement() <em>Statement</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStatement()
   * @generated
   * @ordered
   */
  protected static final String STATEMENT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getStatement() <em>Statement</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStatement()
   * @generated
   * @ordered
   */
  protected String statement = STATEMENT_EDEFAULT;

  /**
   * The cached value of the '{@link #getExpession() <em>Expession</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExpession()
   * @generated
   * @ordered
   */
  protected Expression expession;

  /**
   * The cached value of the '{@link #getOutput() <em>Output</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getOutput()
   * @generated
   * @ordered
   */
  protected Output output;

  /**
   * The default value of the '{@link #getOutputAttribute() <em>Output Attribute</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getOutputAttribute()
   * @generated
   * @ordered
   */
  protected static final String OUTPUT_ATTRIBUTE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getOutputAttribute() <em>Output Attribute</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getOutputAttribute()
   * @generated
   * @ordered
   */
  protected String outputAttribute = OUTPUT_ATTRIBUTE_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected RuleStatementImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MRulesPackage.Literals.RULE_STATEMENT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getStatement()
  {
    return statement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setStatement(String newStatement)
  {
    String oldStatement = statement;
    statement = newStatement;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.RULE_STATEMENT__STATEMENT, oldStatement, statement));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Expression getExpession()
  {
    return expession;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExpession(Expression newExpession, NotificationChain msgs)
  {
    Expression oldExpession = expession;
    expession = newExpession;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MRulesPackage.RULE_STATEMENT__EXPESSION, oldExpession, newExpession);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExpession(Expression newExpession)
  {
    if (newExpession != expession)
    {
      NotificationChain msgs = null;
      if (expession != null)
        msgs = ((InternalEObject)expession).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MRulesPackage.RULE_STATEMENT__EXPESSION, null, msgs);
      if (newExpession != null)
        msgs = ((InternalEObject)newExpession).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MRulesPackage.RULE_STATEMENT__EXPESSION, null, msgs);
      msgs = basicSetExpession(newExpession, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.RULE_STATEMENT__EXPESSION, newExpession, newExpession));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Output getOutput()
  {
    if (output != null && output.eIsProxy())
    {
      InternalEObject oldOutput = (InternalEObject)output;
      output = (Output)eResolveProxy(oldOutput);
      if (output != oldOutput)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MRulesPackage.RULE_STATEMENT__OUTPUT, oldOutput, output));
      }
    }
    return output;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Output basicGetOutput()
  {
    return output;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setOutput(Output newOutput)
  {
    Output oldOutput = output;
    output = newOutput;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.RULE_STATEMENT__OUTPUT, oldOutput, output));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getOutputAttribute()
  {
    return outputAttribute;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setOutputAttribute(String newOutputAttribute)
  {
    String oldOutputAttribute = outputAttribute;
    outputAttribute = newOutputAttribute;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.RULE_STATEMENT__OUTPUT_ATTRIBUTE, oldOutputAttribute, outputAttribute));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MRulesPackage.RULE_STATEMENT__EXPESSION:
        return basicSetExpession(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MRulesPackage.RULE_STATEMENT__STATEMENT:
        return getStatement();
      case MRulesPackage.RULE_STATEMENT__EXPESSION:
        return getExpession();
      case MRulesPackage.RULE_STATEMENT__OUTPUT:
        if (resolve) return getOutput();
        return basicGetOutput();
      case MRulesPackage.RULE_STATEMENT__OUTPUT_ATTRIBUTE:
        return getOutputAttribute();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MRulesPackage.RULE_STATEMENT__STATEMENT:
        setStatement((String)newValue);
        return;
      case MRulesPackage.RULE_STATEMENT__EXPESSION:
        setExpession((Expression)newValue);
        return;
      case MRulesPackage.RULE_STATEMENT__OUTPUT:
        setOutput((Output)newValue);
        return;
      case MRulesPackage.RULE_STATEMENT__OUTPUT_ATTRIBUTE:
        setOutputAttribute((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MRulesPackage.RULE_STATEMENT__STATEMENT:
        setStatement(STATEMENT_EDEFAULT);
        return;
      case MRulesPackage.RULE_STATEMENT__EXPESSION:
        setExpession((Expression)null);
        return;
      case MRulesPackage.RULE_STATEMENT__OUTPUT:
        setOutput((Output)null);
        return;
      case MRulesPackage.RULE_STATEMENT__OUTPUT_ATTRIBUTE:
        setOutputAttribute(OUTPUT_ATTRIBUTE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MRulesPackage.RULE_STATEMENT__STATEMENT:
        return STATEMENT_EDEFAULT == null ? statement != null : !STATEMENT_EDEFAULT.equals(statement);
      case MRulesPackage.RULE_STATEMENT__EXPESSION:
        return expession != null;
      case MRulesPackage.RULE_STATEMENT__OUTPUT:
        return output != null;
      case MRulesPackage.RULE_STATEMENT__OUTPUT_ATTRIBUTE:
        return OUTPUT_ATTRIBUTE_EDEFAULT == null ? outputAttribute != null : !OUTPUT_ATTRIBUTE_EDEFAULT.equals(outputAttribute);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (statement: ");
    result.append(statement);
    result.append(", outputAttribute: ");
    result.append(outputAttribute);
    result.append(')');
    return result.toString();
  }

} //RuleStatementImpl
